<?js
var schemas = DbConnection.schemas();
for (var i = 0; i < schemas.length; i++) {
	?>
	<?js= schemas[i]; ?><br>
	<?js
}
?>

<hr>

<?js
var db = new DbConnection("test01");
if (!db.connection.tableExists("foo"))
	db.execNoResult("CREATE TABLE foo (a INTEGER PRIMARY KEY, b STRING)");
var query = db.prepare("SELECT * FROM foo WHERE a > ?1 AND b LIKE ?2 ORDER BY a DESC LIMIT 10");
var result = query.exec(1, "hello%");
for (var i = 0; i < result.length; i++) {
	var row = result[i];
	for (var j in row) {
		response.write(j + ": " + row[j] + "<br>\n");
	}
	response.write("<br>\n");
}
query.destroy();

//db.execNoResult("INSERT INTO foo (b) VALUES ('hello')");
query = db.prepare("INSERT INTO foo (b) VALUES (?1)");
query.exec("hello");
query.exec("helloa");
query.exec("hellob");
query.exec("helloc");
query.destroy();

try {
	var foo = new adlkjadkljasd();
} catch (ex) {
	response.write('<pre>' + new ExDbError('xxx', 5, ex) + '</pre>');
}

var queryTables = db.prepare("select tbl_name from sqlite_master where type='table'");
var tables = queryTables.exec();
for (var i = 0; i < tables.length; i++) {
	var table = tables[i]['tbl_name'];
	var queryTable = db.prepare("pragma table_info('" + table + "')");
	response.write(table + "<br>\n");
	var tableInfo = queryTable.exec();
	for (var j = 0; j < tableInfo.length; j++) {
		var row = tableInfo[i];
		for (var k in row) {
			response.write(k + ": " + row[k] + "<br>\n");
		}
		response.write("<br>\n");
	}
}
queryTables.destroy();

?>